
<!DOCTYPE HTML>
<html lang="zh-hans" >
<head>
    <meta charset="UTF-8">
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
    <title>14.4：Flutter从启动到显示 · 《Flutter实战》</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="baidu-site-verification" content="Y34sAqDKUH"/>
    <meta name="theme-color" content="#ffffff">
    <!--<meta name="description" content="">-->
    <meta name="description" content="《Flutter实战》是Flutter中文网（https://flutterchina.club）开源的电子书，旨在帮助开发者系统化的了解并学习Flutter。">
    <meta name="keywords" content="flutter实战,flutter书籍,flutter电子书,flutter中文网 ">
    <meta name="generator" content="GitBook 3.2.3">
    
    <meta name="author" content="wendux 824783146@qq.com">
    
    
    
    
    <link rel="stylesheet" href="https://pcdn.flutterchina.club/gitbook/style.css">

    
    
    
    <link rel="stylesheet" href="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-search-pro/search.css">
    
    
    
    <link rel="stylesheet" href="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-ace/ace.css">
    
    
    
    <link rel="stylesheet" href="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-splitter/splitter.css">
    
    
    
    <link rel="stylesheet" href="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-prism/prism.css">
    
    
    
    <link rel="stylesheet" href="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-donate/plugin.css">
    
    
    
    <link rel="stylesheet" href="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-fontsettings/website.css">
    
    
    

    

    
        
    
        
    
        
    
        
    
        
    

    
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="https://pcdn.flutterchina.club/gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="https://pcdn.flutterchina.club/gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="image_and_cache.html" />
    
    
    <link rel="prev" href="render_object.html" />
    

    <style>
        .pull-right > i {
            font-size: 25px;
            color: #777 !important;
            cursor: pointer;

        }

        .pull-right > i:hover {
            color: #777 !important;
        }

        body {
            font-size: 15px !important;
        }

        a[href='../todo.html'], a[href='todo.html'] {
            color: #888 !important;
        }

        .copyright {
            text-align: center;
            margin: 80px 16px 8px 16px;
            padding-top: 16px;
            border-top: #eee 1px solid;
            color: grey;
            font-size: .9em;
        }

        .f-links a{
            text-decoration: underline;
            color: dodgerblue !important;
        }

        .f-links a:hover{
            opacity: .8 !important;
        }

        /*.ad {*/
            /*color: white;*/
            /*text-align: center;*/
            /*background: url(https://img.alicdn.com/tfs/TB1Huu7vMmTBuNjy1XbXXaMrVXa-2880-400.png);*/
            /*background-size: cover;*/
            /*cursor: pointer;*/
            /*margin-bottom: 30px;*/
            /*padding: 18px*/
        /*}*/

        /*.ad:hover {*/
            /*opacity: .8;*/
        /*}*/

        .buy-btn {
            text-decoration: none !important;
            padding: 8px 18px;
            border: #268bd2 1px solid !important;
            display: inline-block !important;
            border-radius: 25px;
            color: #268bd2;
            margin-top: 10px;
        }

        .buy-btn:hover {
            transition: all ease 200ms;
            box-shadow: #555 2px 5px 10px;
            background: #eee;
            color: dodgerblue !important;
        }

        .maoyun{
            padding-top: 5px;
        }


    </style>
</head>
<body>
<!--<div id="ad" style="display: none">-->
<!--<div class="ad ad0"-->
<!--onclick="_track('aliyun','https://promotion.aliyun.com/ntms/yunparter/invite.html?userCode=8hhi4dts')">-->
<!--<div style="font-size: 1.3em; padding-right: 120px; position: relative; top: 12px">阿里云新春特惠</div>-->
<!--<div style="color:orange; font-size: 13px">限时红包 最高￥<span style="font-size: 40px">1888</span></div>-->
<!--</div>-->
<!--<div class="ad ad1"-->
<!--onclick="_track('aliyun-puhui','https://promotion.aliyun.com/ntms/act/qwbk.html?spm=5176.11533457.1089570.10.74e877e33jtaGy&userCode=8hhi4dts')">-->
<!--<div style="font-size: 1.5em;">阿里云全民云计算-新春特惠</div>-->
<!--<div style="color:orange; font-size: 18px;padding-top: 4px;">普惠上云，云服务器1核1G仅需293元/年</div>-->
<!--</div>-->
<!--</div>-->

<div class="ad"  style="text-align:center; padding-bottom:30px; display: none"><a href="https://item.jd.com/12816296.html" onclick="buy('img')" title='点击购买' target="_blank"><img style="height:250px;box-shadow: #aaa 5px 5px 10px;" src="https://pcdn.flutterchina.club/imgs/book.png"/></a>  <br/> <a class="buy-btn" onclick="buy('img')" href="https://item.jd.com/12816296.html" title='点击购买' target="_blank"> 购买实体书 </a></div>


<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    
    
        
        <li>
            <a href="https://flutterchina.club" target="_blank" class="custom-link"><div><img height=20 style='position:relative; top:5px; padding-right:5px ' src='https://cdn.jsdelivr.net/gh/flutterchina/website@1.0/images/favicon.png'/> Flutter中文网</div></a>
        </li>
    
    

    
    <li class="divider"></li>
    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../intro.html">
            
                <a href="../intro.html">
            
                    
                    前言
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">入门篇</li>
        
        
    
        <li class="chapter " data-level="2.1" data-path="../chapter1/">
            
                <a href="../chapter1/">
            
                    
                    第一章：起步
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1.1" data-path="../chapter1/mobile_development_intro.html">
            
                <a href="../chapter1/mobile_development_intro.html">
            
                    
                    1.1：移动开发技术简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2" data-path="../chapter1/flutter_intro.html">
            
                <a href="../chapter1/flutter_intro.html">
            
                    
                    1.2：初识Flutter
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.3" data-path="../chapter1/install_flutter.html">
            
                <a href="../chapter1/install_flutter.html">
            
                    
                    1.3：搭建Flutter开发环境
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.4" data-path="../chapter1/dart.html">
            
                <a href="../chapter1/dart.html">
            
                    
                    1.4：Dart语言简介
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="../chapter2/">
            
                <a href="../chapter2/">
            
                    
                    第二章：第一个Flutter应用
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.2.1" data-path="../chapter2/first_flutter_app.html">
            
                <a href="../chapter2/first_flutter_app.html">
            
                    
                    2.1：计数器示例
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.2" data-path="../chapter2/flutter_router.html">
            
                <a href="../chapter2/flutter_router.html">
            
                    
                    2.2：路由管理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.3" data-path="../chapter2/flutter_package_mgr.html">
            
                <a href="../chapter2/flutter_package_mgr.html">
            
                    
                    2.3：包管理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.4" data-path="../chapter2/flutter_assets_mgr.html">
            
                <a href="../chapter2/flutter_assets_mgr.html">
            
                    
                    2.4：资源管理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.5" data-path="../chapter2/flutter_app_debug.html">
            
                <a href="../chapter2/flutter_app_debug.html">
            
                    
                    2.5：调试Flutter APP
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.6" data-path="../chapter2/thread_model_and_error_report.html">
            
                <a href="../chapter2/thread_model_and_error_report.html">
            
                    
                    2.6：Dart线程模型及异常捕获
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.3" data-path="../chapter3/">
            
                <a href="../chapter3/">
            
                    
                    第三章：基础组件
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.3.1" data-path="../chapter3/flutter_widget_intro.html">
            
                <a href="../chapter3/flutter_widget_intro.html">
            
                    
                    3.1：Widget简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.2" data-path="../chapter3/state_manage.html">
            
                <a href="../chapter3/state_manage.html">
            
                    
                    3.2：状态管理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.3" data-path="../chapter3/text.html">
            
                <a href="../chapter3/text.html">
            
                    
                    3.3：文本、字体样式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.4" data-path="../chapter3/buttons.html">
            
                <a href="../chapter3/buttons.html">
            
                    
                    3.4：按钮
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.5" data-path="../chapter3/img_and_icon.html">
            
                <a href="../chapter3/img_and_icon.html">
            
                    
                    3.5：图片和Icon
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.6" data-path="../chapter3/radio_and_checkbox.html">
            
                <a href="../chapter3/radio_and_checkbox.html">
            
                    
                    3.6：单选框和复选框
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.7" data-path="../chapter3/input_and_form.html">
            
                <a href="../chapter3/input_and_form.html">
            
                    
                    3.7：输入框和表单
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.8" data-path="../chapter3/progress.html">
            
                <a href="../chapter3/progress.html">
            
                    
                    3.8：进度指示器
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.4" data-path="../chapter4/">
            
                <a href="../chapter4/">
            
                    
                    第四章：布局类组件
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.4.1" data-path="../chapter4/intro.html">
            
                <a href="../chapter4/intro.html">
            
                    
                    4.1：布局类组件简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.4.2" data-path="../chapter4/row_and_column.html">
            
                <a href="../chapter4/row_and_column.html">
            
                    
                    4.2：线性布局（Row、Column）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.4.3" data-path="../chapter4/flex.html">
            
                <a href="../chapter4/flex.html">
            
                    
                    4.3：弹性布局（Flex）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.4.4" data-path="../chapter4/wrap_and_flow.html">
            
                <a href="../chapter4/wrap_and_flow.html">
            
                    
                    4.4：流式布局（Wrap、Flow）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.4.5" data-path="../chapter4/stack.html">
            
                <a href="../chapter4/stack.html">
            
                    
                    4.5：层叠布局（Stack、Positioned）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.4.6" data-path="../chapter4/alignment.html">
            
                <a href="../chapter4/alignment.html">
            
                    
                    4.6：对齐与相对定位（Align）
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.5" data-path="../chapter5/">
            
                <a href="../chapter5/">
            
                    
                    第五章：容器类组件
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.5.1" data-path="../chapter5/padding.html">
            
                <a href="../chapter5/padding.html">
            
                    
                    5.1：填充（Padding）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.5.2" data-path="../chapter5/constrainedbox_and_sizebox.html">
            
                <a href="../chapter5/constrainedbox_and_sizebox.html">
            
                    
                    5.2：尺寸限制类容器（ConstrainedBox等）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.5.3" data-path="../chapter5/decoratedbox.html">
            
                <a href="../chapter5/decoratedbox.html">
            
                    
                    5.3：装饰容器（DecoratedBox）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.5.4" data-path="../chapter5/transform.html">
            
                <a href="../chapter5/transform.html">
            
                    
                    5.4：变换（Transform）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.5.5" data-path="../chapter5/container.html">
            
                <a href="../chapter5/container.html">
            
                    
                    5.5：Container容器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.5.6" data-path="../chapter5/material_scaffold.html">
            
                <a href="../chapter5/material_scaffold.html">
            
                    
                    5.6：Scaffold、TabBar、底部导航
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.5.7" data-path="../chapter5/clip.html">
            
                <a href="../chapter5/clip.html">
            
                    
                    5.7：剪裁（Clip）
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.6" data-path="../chapter6/">
            
                <a href="../chapter6/">
            
                    
                    第六章：可滚动组件
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.6.1" data-path="../chapter6/intro.html">
            
                <a href="../chapter6/intro.html">
            
                    
                    6.1：可滚动组件简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.6.2" data-path="../chapter6/single_child_scrollview.html">
            
                <a href="../chapter6/single_child_scrollview.html">
            
                    
                    6.2：SingleChildScrollView
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.6.3" data-path="../chapter6/listview.html">
            
                <a href="../chapter6/listview.html">
            
                    
                    6.3：ListView
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.6.4" data-path="../chapter6/gridview.html">
            
                <a href="../chapter6/gridview.html">
            
                    
                    6.4：GridView
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.6.5" data-path="../chapter6/custom_scrollview.html">
            
                <a href="../chapter6/custom_scrollview.html">
            
                    
                    6.5：CustomScrollView
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.6.6" data-path="../chapter6/scroll_controller.html">
            
                <a href="../chapter6/scroll_controller.html">
            
                    
                    6.6：滚动监听及控制（ScrollController）
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.7" data-path="../chapter7/">
            
                <a href="../chapter7/">
            
                    
                    第七章：功能型组件
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.7.1" data-path="../chapter7/willpopscope.html">
            
                <a href="../chapter7/willpopscope.html">
            
                    
                    7.1：导航返回拦截（WillPopScope）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.7.2" data-path="../chapter7/inherited_widget.html">
            
                <a href="../chapter7/inherited_widget.html">
            
                    
                    7.2：数据共享（InheritedWidget）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.7.3" data-path="../chapter7/provider.html">
            
                <a href="../chapter7/provider.html">
            
                    
                    7.3： 跨组件状态共享（Provider）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.7.4" data-path="../chapter7/theme.html">
            
                <a href="../chapter7/theme.html">
            
                    
                    7.4：颜色和主题（Theme）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.7.5" data-path="../chapter7/futurebuilder_and_streambuilder.html">
            
                <a href="../chapter7/futurebuilder_and_streambuilder.html">
            
                    
                    7.5：异步UI更新（FutureBuilder、StreamBuilder）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.7.6" data-path="../chapter7/dailog.html">
            
                <a href="../chapter7/dailog.html">
            
                    
                    7.6：对话框详解
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    
        
        <li class="header">进阶篇</li>
        
        
    
        <li class="chapter " data-level="3.1" data-path="../chapter8/">
            
                <a href="../chapter8/">
            
                    
                    第八章：事件处理与通知
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.1.1" data-path="../chapter8/listener.html">
            
                <a href="../chapter8/listener.html">
            
                    
                    8.1：原始指针事件处理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.1.2" data-path="../chapter8/gesture.html">
            
                <a href="../chapter8/gesture.html">
            
                    
                    8.2：手势识别
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.1.3" data-path="../chapter8/eventbus.html">
            
                <a href="../chapter8/eventbus.html">
            
                    
                    8.3：全局事件总线
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.1.4" data-path="../chapter8/notification.html">
            
                <a href="../chapter8/notification.html">
            
                    
                    8.4：通知(Notification)
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="../chapter9/">
            
                <a href="../chapter9/">
            
                    
                    第九章：动画
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.2.1" data-path="../chapter9/intro.html">
            
                <a href="../chapter9/intro.html">
            
                    
                    9.1：Flutter动画简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2.2" data-path="../chapter9/animation_structure.html">
            
                <a href="../chapter9/animation_structure.html">
            
                    
                    9.2：动画结构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2.3" data-path="../chapter9/route_transition.html">
            
                <a href="../chapter9/route_transition.html">
            
                    
                    9.3：自定义路由过渡动画
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2.4" data-path="../chapter9/hero.html">
            
                <a href="../chapter9/hero.html">
            
                    
                    9.4：Hero动画
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2.5" data-path="../chapter9/stagger_animation.html">
            
                <a href="../chapter9/stagger_animation.html">
            
                    
                    9.5：交织动画
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2.6" data-path="../chapter9/animated_switcher.html">
            
                <a href="../chapter9/animated_switcher.html">
            
                    
                    9.6：通用“动画切换”组件（AnimatedSwitcher）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2.7" data-path="../chapter9/animated_widgets.html">
            
                <a href="../chapter9/animated_widgets.html">
            
                    
                    9.7：动画过渡组件
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="../chapter10/">
            
                <a href="../chapter10/">
            
                    
                    第十章：自定义组件
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.3.1" data-path="../chapter10/intro.html">
            
                <a href="../chapter10/intro.html">
            
                    
                    10.1：自定义组件方法简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3.2" data-path="../chapter10/combine.html">
            
                <a href="../chapter10/combine.html">
            
                    
                    10.2：组合现有组件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3.3" data-path="../chapter10/turn_box.html">
            
                <a href="../chapter10/turn_box.html">
            
                    
                    10.3：组合实例：TurnBox
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3.4" data-path="../chapter10/custom_paint.html">
            
                <a href="../chapter10/custom_paint.html">
            
                    
                    10.4：自绘组件（CustomPaint与Canvas）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3.5" data-path="../chapter10/gradient_circular_progress_demo.html">
            
                <a href="../chapter10/gradient_circular_progress_demo.html">
            
                    
                    10.5：自绘实例：圆形渐变进度条(自绘)
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.4" data-path="../chapter11/">
            
                <a href="../chapter11/">
            
                    
                    第十一章：文件操作与网络请求
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.4.1" data-path="../chapter11/file_operation.html">
            
                <a href="../chapter11/file_operation.html">
            
                    
                    11.1：文件操作
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4.2" data-path="../chapter11/http.html">
            
                <a href="../chapter11/http.html">
            
                    
                    11.2：Http请求-HttpClient
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4.3" data-path="../chapter11/dio.html">
            
                <a href="../chapter11/dio.html">
            
                    
                    11.3：Http请求-Dio package
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4.4" data-path="../chapter11/download_with_chunks.html">
            
                <a href="../chapter11/download_with_chunks.html">
            
                    
                    11.4：实例：Http分块下载
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4.5" data-path="../chapter11/websocket.html">
            
                <a href="../chapter11/websocket.html">
            
                    
                    11.5：WebSocket
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4.6" data-path="../chapter11/socket.html">
            
                <a href="../chapter11/socket.html">
            
                    
                    11.6：使用Socket API
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4.7" data-path="../chapter11/json_model.html">
            
                <a href="../chapter11/json_model.html">
            
                    
                    11.7：Json转Dart Model类
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.5" data-path="../chapter12/">
            
                <a href="../chapter12/">
            
                    
                    第十二章：包与插件
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.5.1" data-path="../chapter12/develop_package.html">
            
                <a href="../chapter12/develop_package.html">
            
                    
                    12.1：开发package
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5.2" data-path="../chapter12/platform-channel.html">
            
                <a href="../chapter12/platform-channel.html">
            
                    
                    12.2：平台通道简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5.3" data-path="../chapter12/develop_plugin.html">
            
                <a href="../chapter12/develop_plugin.html">
            
                    
                    12.3：开发Flutter插件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5.4" data-path="../chapter12/android_implement.html">
            
                <a href="../chapter12/android_implement.html">
            
                    
                    12.4：插件开发：实现Android端API
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5.5" data-path="../chapter12/ios_implement.html">
            
                <a href="../chapter12/ios_implement.html">
            
                    
                    12.5：插件开发：实现IOS端API
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5.6" data-path="../chapter12/texture_platformview.html">
            
                <a href="../chapter12/texture_platformview.html">
            
                    
                    12.6：Texture和PlatformView
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.6" data-path="../chapter13/">
            
                <a href="../chapter13/">
            
                    
                    第十三章：国际化
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.6.1" data-path="../chapter13/multi_languages_support.html">
            
                <a href="../chapter13/multi_languages_support.html">
            
                    
                    13.1：让App支持多语言
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.6.2" data-path="../chapter13/locallization_implement.html">
            
                <a href="../chapter13/locallization_implement.html">
            
                    
                    13.2：实现Localizations
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.6.3" data-path="../chapter13/intl.html">
            
                <a href="../chapter13/intl.html">
            
                    
                    13.3：使用Intl包
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.6.4" data-path="../chapter13/faq.html">
            
                <a href="../chapter13/faq.html">
            
                    
                    13.4：国际化常见问题
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.7" data-path="./">
            
                <a href="./">
            
                    
                    第十四章：Flutter核心原理
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.7.1" data-path="flutter_ui_system.html">
            
                <a href="flutter_ui_system.html">
            
                    
                    14.1：Flutter UI系统
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.7.2" data-path="element_buildcontext.html">
            
                <a href="element_buildcontext.html">
            
                    
                    14.2：Element和BuildContext
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.7.3" data-path="render_object.html">
            
                <a href="render_object.html">
            
                    
                    14.3：RenderObject与RenderBox
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="3.7.4" data-path="flutter_app_startup.html">
            
                <a href="flutter_app_startup.html">
            
                    
                    14.4：Flutter从启动到显示
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.7.5" data-path="image_and_cache.html">
            
                <a href="image_and_cache.html">
            
                    
                    14.5：Flutter图片加载与缓存
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    
        
        <li class="header">实例篇</li>
        
        
    
        <li class="chapter " data-level="4.1" data-path="../chapter15/intro.html">
            
                <a href="../chapter15/intro.html">
            
                    
                    第十五章：一个完整的Flutter应用
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.1.1" data-path="../chapter15/intro.html">
            
                <a href="../chapter15/intro.html">
            
                    
                    15.1：应用简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.2" data-path="../chapter15/code_structure.html">
            
                <a href="../chapter15/code_structure.html">
            
                    
                    15.2：APP代码结构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.3" data-path="../chapter15/models.html">
            
                <a href="../chapter15/models.html">
            
                    
                    15.3：Model类定义
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.4" data-path="../chapter15/globals.html">
            
                <a href="../chapter15/globals.html">
            
                    
                    15.4：全局变量及共享状态
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.5" data-path="../chapter15/network.html">
            
                <a href="../chapter15/network.html">
            
                    
                    15.5：网络请求封装
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.6" data-path="../chapter15/entry.html">
            
                <a href="../chapter15/entry.html">
            
                    
                    15.6：App入口及首页
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.7" data-path="../chapter15/login_page.html">
            
                <a href="../chapter15/login_page.html">
            
                    
                    15.7：登录页
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.8" data-path="../chapter15/language_and_theme_setting.html">
            
                <a href="../chapter15/language_and_theme_setting.html">
            
                    
                    15.8：多语言和多主题
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="https://pcdn.flutterchina.club/gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    
    <a class="btn pull-right" aria-label="GitHub">
        <i class="fa fa-edit" title="编辑本文"></i>
    </a>
    <a class="btn pull-right" aria-label="GitHub" href="https://github.com/flutterchina/flutter-in-action">
        <i class="fa fa-github" title="查看本书开源项目"></i>
    </a>
    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >14.4：Flutter从启动到显示</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="144-flutter&#x8FD0;&#x884C;&#x673A;&#x5236;-&#x4ECE;&#x542F;&#x52A8;&#x5230;&#x663E;&#x793A;">14.4 Flutter&#x8FD0;&#x884C;&#x673A;&#x5236;-&#x4ECE;&#x542F;&#x52A8;&#x5230;&#x663E;&#x793A;</h1>
<p>&#x672C;&#x8282;&#x6211;&#x4EEC;&#x4E3B;&#x8981;&#x4ECB;&#x7ECD;&#x4E00;&#x4E0B;Flutter&#x4ECE;&#x542F;&#x52A8;&#x5230;&#x663E;&#x793A;&#x7684;&#x8FC7;&#x7A0B;&#x3002;</p>
<h3 id="&#x542F;&#x52A8;">&#x542F;&#x52A8;</h3>
<p>Flutter&#x7684;&#x5165;&#x53E3;&#x5728;&quot;lib/main.dart&quot;&#x7684;<code>main()</code>&#x51FD;&#x6570;&#x4E2D;&#xFF0C;&#x5B83;&#x662F;Dart&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x7684;&#x8D77;&#x70B9;&#x3002;&#x5728;Flutter&#x5E94;&#x7528;&#x4E2D;&#xFF0C;<code>main()</code>&#x51FD;&#x6570;&#x6700;&#x7B80;&#x5355;&#x7684;&#x5B9E;&#x73B0;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre class="language-"><code class="lang-dart"><span class="token keyword">void</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token function">runApp</span><span class="token punctuation">(</span><span class="token function">MyApp</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x53EF;&#x4EE5;&#x770B;<code>main()</code>&#x51FD;&#x6570;&#x53EA;&#x8C03;&#x7528;&#x4E86;&#x4E00;&#x4E2A;<code>runApp()</code>&#x65B9;&#x6CD5;&#xFF0C;&#x6211;&#x4EEC;&#x770B;&#x770B;<code>runApp()</code>&#x65B9;&#x6CD5;&#x4E2D;&#x90FD;&#x505A;&#x4E86;&#x4EC0;&#x4E48;&#xFF1A;</p>
<pre class="language-"><code class="lang-dart"><span class="token keyword">void</span> <span class="token function">runApp</span><span class="token punctuation">(</span>Widget app<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  WidgetsFlutterBinding<span class="token punctuation">.</span><span class="token function">ensureInitialized</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token function">attachRootWidget</span><span class="token punctuation">(</span>app<span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token function">scheduleWarmUpFrame</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x53C2;&#x6570;<code>app</code>&#x662F;&#x4E00;&#x4E2A;widget&#xFF0C;&#x5B83;&#x662F;Flutter&#x5E94;&#x7528;&#x542F;&#x52A8;&#x540E;&#x8981;&#x5C55;&#x793A;&#x7684;&#x7B2C;&#x4E00;&#x4E2A;Widget&#x3002;&#x800C;<code>WidgetsFlutterBinding</code>&#x6B63;&#x662F;&#x7ED1;&#x5B9A;widget &#x6846;&#x67B6;&#x548C;Flutter engine&#x7684;&#x6865;&#x6881;&#xFF0C;&#x5B9A;&#x4E49;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre class="language-"><code class="lang-dart"><span class="token keyword">class</span> <span class="token class-name">WidgetsFlutterBinding</span> <span class="token keyword">extends</span> <span class="token class-name">BindingBase</span> <span class="token keyword">with</span> GestureBinding<span class="token punctuation">,</span> ServicesBinding<span class="token punctuation">,</span> SchedulerBinding<span class="token punctuation">,</span> PaintingBinding<span class="token punctuation">,</span> SemanticsBinding<span class="token punctuation">,</span> RendererBinding<span class="token punctuation">,</span> WidgetsBinding <span class="token punctuation">{</span>
  <span class="token keyword">static</span> WidgetsBinding <span class="token function">ensureInitialized</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span>WidgetsBinding<span class="token punctuation">.</span>instance <span class="token operator">==</span> <span class="token keyword">null</span><span class="token punctuation">)</span>
      <span class="token function">WidgetsFlutterBinding</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">return</span> WidgetsBinding<span class="token punctuation">.</span>instance<span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x53EF;&#x4EE5;&#x770B;&#x5230;<code>WidgetsFlutterBinding</code>&#x7EE7;&#x627F;&#x81EA;<code>BindingBase</code> &#x5E76;&#x6DF7;&#x5165;&#x4E86;&#x5F88;&#x591A;<code>Binding</code>&#xFF0C;&#x5728;&#x4ECB;&#x7ECD;&#x8FD9;&#x4E9B;<code>Binding</code>&#x4E4B;&#x524D;&#x6211;&#x4EEC;&#x5148;&#x4ECB;&#x7ECD;&#x4E00;&#x4E0B;<code>Window</code>&#xFF0C;&#x4E0B;&#x9762;&#x662F;<code>Window</code>&#x7684;&#x5B98;&#x65B9;&#x89E3;&#x91CA;&#xFF1A;</p>
<blockquote>
<p>The most basic interface to the host operating system&apos;s user interface.</p>
</blockquote>
<p>&#x5F88;&#x660E;&#x663E;&#xFF0C;<code>Window</code>&#x6B63;&#x662F;Flutter Framework&#x8FDE;&#x63A5;&#x5BBF;&#x4E3B;&#x64CD;&#x4F5C;&#x7CFB;&#x7EDF;&#x7684;&#x63A5;&#x53E3;&#x3002;&#x6211;&#x4EEC;&#x770B;&#x4E00;&#x4E0B;<code>Window</code>&#x7C7B;&#x7684;&#x90E8;&#x5206;&#x5B9A;&#x4E49;&#xFF1A;</p>
<pre class="language-"><code class="lang-dart"><span class="token keyword">class</span> <span class="token class-name">Window</span> <span class="token punctuation">{</span>

  <span class="token comment">// &#x5F53;&#x524D;&#x8BBE;&#x5907;&#x7684;DPI&#xFF0C;&#x5373;&#x4E00;&#x4E2A;&#x903B;&#x8F91;&#x50CF;&#x7D20;&#x663E;&#x793A;&#x591A;&#x5C11;&#x7269;&#x7406;&#x50CF;&#x7D20;&#xFF0C;&#x6570;&#x5B57;&#x8D8A;&#x5927;&#xFF0C;&#x663E;&#x793A;&#x6548;&#x679C;&#x5C31;&#x8D8A;&#x7CBE;&#x7EC6;&#x4FDD;&#x771F;&#x3002;</span>
  <span class="token comment">// DPI&#x662F;&#x8BBE;&#x5907;&#x5C4F;&#x5E55;&#x7684;&#x56FA;&#x4EF6;&#x5C5E;&#x6027;&#xFF0C;&#x5982;Nexus 6&#x7684;&#x5C4F;&#x5E55;DPI&#x4E3A;3.5 </span>
  double <span class="token keyword">get</span> devicePixelRatio <span class="token operator">=</span><span class="token operator">&gt;</span> _devicePixelRatio<span class="token punctuation">;</span>

  <span class="token comment">// Flutter UI&#x7ED8;&#x5236;&#x533A;&#x57DF;&#x7684;&#x5927;&#x5C0F;</span>
  Size <span class="token keyword">get</span> physicalSize <span class="token operator">=</span><span class="token operator">&gt;</span> _physicalSize<span class="token punctuation">;</span>

  <span class="token comment">// &#x5F53;&#x524D;&#x7CFB;&#x7EDF;&#x9ED8;&#x8BA4;&#x7684;&#x8BED;&#x8A00;Locale</span>
  Locale <span class="token keyword">get</span> locale<span class="token punctuation">;</span>

  <span class="token comment">// &#x5F53;&#x524D;&#x7CFB;&#x7EDF;&#x5B57;&#x4F53;&#x7F29;&#x653E;&#x6BD4;&#x4F8B;&#x3002;  </span>
  double <span class="token keyword">get</span> textScaleFactor <span class="token operator">=</span><span class="token operator">&gt;</span> _textScaleFactor<span class="token punctuation">;</span>  

  <span class="token comment">// &#x5F53;&#x7ED8;&#x5236;&#x533A;&#x57DF;&#x5927;&#x5C0F;&#x6539;&#x53D8;&#x56DE;&#x8C03;</span>
  VoidCallback <span class="token keyword">get</span> onMetricsChanged <span class="token operator">=</span><span class="token operator">&gt;</span> _onMetricsChanged<span class="token punctuation">;</span>  
  <span class="token comment">// Locale&#x53D1;&#x751F;&#x53D8;&#x5316;&#x56DE;&#x8C03;</span>
  VoidCallback <span class="token keyword">get</span> onLocaleChanged <span class="token operator">=</span><span class="token operator">&gt;</span> _onLocaleChanged<span class="token punctuation">;</span>
  <span class="token comment">// &#x7CFB;&#x7EDF;&#x5B57;&#x4F53;&#x7F29;&#x653E;&#x53D8;&#x5316;&#x56DE;&#x8C03;</span>
  VoidCallback <span class="token keyword">get</span> onTextScaleFactorChanged <span class="token operator">=</span><span class="token operator">&gt;</span> _onTextScaleFactorChanged<span class="token punctuation">;</span>
  <span class="token comment">// &#x7ED8;&#x5236;&#x524D;&#x56DE;&#x8C03;&#xFF0C;&#x4E00;&#x822C;&#x4F1A;&#x53D7;&#x663E;&#x793A;&#x5668;&#x7684;&#x5782;&#x76F4;&#x540C;&#x6B65;&#x4FE1;&#x53F7;VSync&#x9A71;&#x52A8;&#xFF0C;&#x5F53;&#x5C4F;&#x5E55;&#x5237;&#x65B0;&#x65F6;&#x5C31;&#x4F1A;&#x88AB;&#x8C03;&#x7528;</span>
  FrameCallback <span class="token keyword">get</span> onBeginFrame <span class="token operator">=</span><span class="token operator">&gt;</span> _onBeginFrame<span class="token punctuation">;</span>
  <span class="token comment">// &#x7ED8;&#x5236;&#x56DE;&#x8C03;  </span>
  VoidCallback <span class="token keyword">get</span> onDrawFrame <span class="token operator">=</span><span class="token operator">&gt;</span> _onDrawFrame<span class="token punctuation">;</span>
  <span class="token comment">// &#x70B9;&#x51FB;&#x6216;&#x6307;&#x9488;&#x4E8B;&#x4EF6;&#x56DE;&#x8C03;</span>
  PointerDataPacketCallback <span class="token keyword">get</span> onPointerDataPacket <span class="token operator">=</span><span class="token operator">&gt;</span> _onPointerDataPacket<span class="token punctuation">;</span>
  <span class="token comment">// &#x8C03;&#x5EA6;Frame&#xFF0C;&#x8BE5;&#x65B9;&#x6CD5;&#x6267;&#x884C;&#x540E;&#xFF0C;onBeginFrame&#x548C;onDrawFrame&#x5C06;&#x7D27;&#x63A5;&#x7740;&#x4F1A;&#x5728;&#x5408;&#x9002;&#x65F6;&#x673A;&#x88AB;&#x8C03;&#x7528;&#xFF0C;</span>
  <span class="token comment">// &#x6B64;&#x65B9;&#x6CD5;&#x4F1A;&#x76F4;&#x63A5;&#x8C03;&#x7528;Flutter engine&#x7684;Window_scheduleFrame&#x65B9;&#x6CD5;</span>
  <span class="token keyword">void</span> <span class="token function">scheduleFrame</span><span class="token punctuation">(</span><span class="token punctuation">)</span> native <span class="token string">&apos;Window_scheduleFrame&apos;</span><span class="token punctuation">;</span>
  <span class="token comment">// &#x66F4;&#x65B0;&#x5E94;&#x7528;&#x5728;GPU&#x4E0A;&#x7684;&#x6E32;&#x67D3;,&#x6B64;&#x65B9;&#x6CD5;&#x4F1A;&#x76F4;&#x63A5;&#x8C03;&#x7528;Flutter engine&#x7684;Window_render&#x65B9;&#x6CD5;</span>
  <span class="token keyword">void</span> <span class="token function">render</span><span class="token punctuation">(</span>Scene scene<span class="token punctuation">)</span> native <span class="token string">&apos;Window_render&apos;</span><span class="token punctuation">;</span>

  <span class="token comment">// &#x53D1;&#x9001;&#x5E73;&#x53F0;&#x6D88;&#x606F;</span>
  <span class="token keyword">void</span> <span class="token function">sendPlatformMessage</span><span class="token punctuation">(</span>String name<span class="token punctuation">,</span>
                           ByteData data<span class="token punctuation">,</span>
                           PlatformMessageResponseCallback callback<span class="token punctuation">)</span> <span class="token punctuation">;</span>
  <span class="token comment">// &#x5E73;&#x53F0;&#x901A;&#x9053;&#x6D88;&#x606F;&#x5904;&#x7406;&#x56DE;&#x8C03;  </span>
  PlatformMessageCallback <span class="token keyword">get</span> onPlatformMessage <span class="token operator">=</span><span class="token operator">&gt;</span> _onPlatformMessage<span class="token punctuation">;</span>

  <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span> <span class="token comment">//&#x5176;&#x5B83;&#x5C5E;&#x6027;&#x53CA;&#x56DE;&#x8C03;</span>

<span class="token punctuation">}</span>
</code></pre>
<p>&#x53EF;&#x4EE5;&#x770B;&#x5230;<code>Window</code>&#x7C7B;&#x5305;&#x542B;&#x4E86;&#x5F53;&#x524D;&#x8BBE;&#x5907;&#x548C;&#x7CFB;&#x7EDF;&#x7684;&#x4E00;&#x4E9B;&#x4FE1;&#x606F;&#x4EE5;&#x53CA;Flutter Engine&#x7684;&#x4E00;&#x4E9B;&#x56DE;&#x8C03;&#x3002;&#x73B0;&#x5728;&#x6211;&#x4EEC;&#x518D;&#x56DE;&#x6765;&#x770B;&#x770B;<code>WidgetsFlutterBinding</code>&#x6DF7;&#x5165;&#x7684;&#x5404;&#x79CD;Binding&#x3002;&#x901A;&#x8FC7;&#x67E5;&#x770B;&#x8FD9;&#x4E9B; Binding&#x7684;&#x6E90;&#x7801;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x53D1;&#x73B0;&#x8FD9;&#x4E9B;Binding&#x4E2D;&#x57FA;&#x672C;&#x90FD;&#x662F;&#x76D1;&#x542C;&#x5E76;&#x5904;&#x7406;<code>Window</code>&#x5BF9;&#x8C61;&#x7684;&#x4E00;&#x4E9B;&#x4E8B;&#x4EF6;&#xFF0C;&#x7136;&#x540E;&#x5C06;&#x8FD9;&#x4E9B;&#x4E8B;&#x4EF6;&#x6309;&#x7167;Framework&#x7684;&#x6A21;&#x578B;&#x5305;&#x88C5;&#x3001;&#x62BD;&#x8C61;&#x7136;&#x540E;&#x5206;&#x53D1;&#x3002;&#x53EF;&#x4EE5;&#x770B;&#x5230;<code>WidgetsFlutterBinding</code>&#x6B63;&#x662F;&#x7C98;&#x8FDE;Flutter engine&#x4E0E;&#x4E0A;&#x5C42;Framework&#x7684;&#x201C;&#x80F6;&#x6C34;&#x201D;&#x3002;</p>
<ul>
<li><code>GestureBinding</code>&#xFF1A;&#x63D0;&#x4F9B;&#x4E86;<code>window.onPointerDataPacket</code> &#x56DE;&#x8C03;&#xFF0C;&#x7ED1;&#x5B9A;Framework&#x624B;&#x52BF;&#x5B50;&#x7CFB;&#x7EDF;&#xFF0C;&#x662F;Framework&#x4E8B;&#x4EF6;&#x6A21;&#x578B;&#x4E0E;&#x5E95;&#x5C42;&#x4E8B;&#x4EF6;&#x7684;&#x7ED1;&#x5B9A;&#x5165;&#x53E3;&#x3002;</li>
<li><code>ServicesBinding</code>&#xFF1A;&#x63D0;&#x4F9B;&#x4E86;<code>window.onPlatformMessage</code> &#x56DE;&#x8C03;&#xFF0C; &#x7528;&#x4E8E;&#x7ED1;&#x5B9A;&#x5E73;&#x53F0;&#x6D88;&#x606F;&#x901A;&#x9053;&#xFF08;message channel&#xFF09;&#xFF0C;&#x4E3B;&#x8981;&#x5904;&#x7406;&#x539F;&#x751F;&#x548C;Flutter&#x901A;&#x4FE1;&#x3002;</li>
<li><code>SchedulerBinding</code>&#xFF1A;&#x63D0;&#x4F9B;&#x4E86;<code>window.onBeginFrame</code>&#x548C;<code>window.onDrawFrame</code>&#x56DE;&#x8C03;&#xFF0C;&#x76D1;&#x542C;&#x5237;&#x65B0;&#x4E8B;&#x4EF6;&#xFF0C;&#x7ED1;&#x5B9A;Framework&#x7ED8;&#x5236;&#x8C03;&#x5EA6;&#x5B50;&#x7CFB;&#x7EDF;&#x3002;</li>
<li><code>PaintingBinding</code>&#xFF1A;&#x7ED1;&#x5B9A;&#x7ED8;&#x5236;&#x5E93;&#xFF0C;&#x4E3B;&#x8981;&#x7528;&#x4E8E;&#x5904;&#x7406;&#x56FE;&#x7247;&#x7F13;&#x5B58;&#x3002;</li>
<li><code>SemanticsBinding</code>&#xFF1A;&#x8BED;&#x4E49;&#x5316;&#x5C42;&#x4E0E;Flutter engine&#x7684;&#x6865;&#x6881;&#xFF0C;&#x4E3B;&#x8981;&#x662F;&#x8F85;&#x52A9;&#x529F;&#x80FD;&#x7684;&#x5E95;&#x5C42;&#x652F;&#x6301;&#x3002;</li>
<li><code>RendererBinding</code>: &#x63D0;&#x4F9B;&#x4E86;<code>window.onMetricsChanged</code> &#x3001;<code>window.onTextScaleFactorChanged</code> &#x7B49;&#x56DE;&#x8C03;&#x3002;&#x5B83;&#x662F;&#x6E32;&#x67D3;&#x6811;&#x4E0E;Flutter engine&#x7684;&#x6865;&#x6881;&#x3002;</li>
<li><code>WidgetsBinding</code>&#xFF1A;&#x63D0;&#x4F9B;&#x4E86;<code>window.onLocaleChanged</code>&#x3001;<code>onBuildScheduled</code> &#x7B49;&#x56DE;&#x8C03;&#x3002;&#x5B83;&#x662F;Flutter widget&#x5C42;&#x4E0E;engine&#x7684;&#x6865;&#x6881;&#x3002;</li>
</ul>
<p><code>WidgetsFlutterBinding.ensureInitialized()</code>&#x8D1F;&#x8D23;&#x521D;&#x59CB;&#x5316;&#x4E00;&#x4E2A;<code>WidgetsBinding</code>&#x7684;&#x5168;&#x5C40;&#x5355;&#x4F8B;&#xFF0C;&#x7D27;&#x63A5;&#x7740;&#x4F1A;&#x8C03;&#x7528;<code>WidgetsBinding</code>&#x7684;<code>attachRootWidget</code>&#x65B9;&#x6CD5;&#xFF0C;&#x8BE5;&#x65B9;&#x6CD5;&#x8D1F;&#x8D23;&#x5C06;&#x6839;Widget&#x6DFB;&#x52A0;&#x5230;<code>RenderView</code>&#x4E0A;&#xFF0C;&#x4EE3;&#x7801;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre class="language-"><code class="lang-dart"><span class="token keyword">void</span> <span class="token function">attachRootWidget</span><span class="token punctuation">(</span>Widget rootWidget<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  _renderViewElement <span class="token operator">=</span> RenderObjectToWidgetAdapter<span class="token operator">&lt;</span>RenderBox<span class="token operator">&gt;</span><span class="token punctuation">(</span>
    container<span class="token punctuation">:</span> renderView<span class="token punctuation">,</span> 
    debugShortDescription<span class="token punctuation">:</span> <span class="token string">&apos;[root]&apos;</span><span class="token punctuation">,</span>
    child<span class="token punctuation">:</span> rootWidget
  <span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">attachToRenderTree</span><span class="token punctuation">(</span>buildOwner<span class="token punctuation">,</span> renderViewElement<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x6CE8;&#x610F;&#xFF0C;&#x4EE3;&#x7801;&#x4E2D;&#x7684;&#x6709;<code>renderView</code>&#x548C;<code>renderViewElement</code>&#x4E24;&#x4E2A;&#x53D8;&#x91CF;&#xFF0C;<code>renderView</code>&#x662F;&#x4E00;&#x4E2A;<code>RenderObject</code>&#xFF0C;&#x5B83;&#x662F;&#x6E32;&#x67D3;&#x6811;&#x7684;&#x6839;&#xFF0C;&#x800C;<code>renderViewElement</code>&#x662F;<code>renderView</code>&#x5BF9;&#x5E94;&#x7684;<code>Element</code>&#x5BF9;&#x8C61;&#xFF0C;&#x53EF;&#x89C1;&#x8BE5;&#x65B9;&#x6CD5;&#x4E3B;&#x8981;&#x5B8C;&#x6210;&#x4E86;&#x6839;widget&#x5230;&#x6839; <code>RenderObject</code>&#x518D;&#x5230;&#x6839;<code>Element</code>&#x7684;&#x6574;&#x4E2A;&#x5173;&#x8054;&#x8FC7;&#x7A0B;&#x3002;&#x6211;&#x4EEC;&#x770B;&#x770B;<code>attachToRenderTree</code>&#x7684;&#x6E90;&#x7801;&#x5B9E;&#x73B0;&#xFF1A;</p>
<pre class="language-"><code class="lang-dart">RenderObjectToWidgetElement<span class="token operator">&lt;</span>T<span class="token operator">&gt;</span> <span class="token function">attachToRenderTree</span><span class="token punctuation">(</span>BuildOwner owner<span class="token punctuation">,</span> <span class="token punctuation">[</span>RenderObjectToWidgetElement<span class="token operator">&lt;</span>T<span class="token operator">&gt;</span> element<span class="token punctuation">]</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">if</span> <span class="token punctuation">(</span>element <span class="token operator">==</span> <span class="token keyword">null</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    owner<span class="token punctuation">.</span><span class="token function">lockState</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
      element <span class="token operator">=</span> <span class="token function">createElement</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
      <span class="token keyword">assert</span><span class="token punctuation">(</span>element <span class="token operator">!=</span> <span class="token keyword">null</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
      element<span class="token punctuation">.</span><span class="token function">assignOwner</span><span class="token punctuation">(</span>owner<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    owner<span class="token punctuation">.</span><span class="token function">buildScope</span><span class="token punctuation">(</span>element<span class="token punctuation">,</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
      element<span class="token punctuation">.</span><span class="token function">mount</span><span class="token punctuation">(</span><span class="token keyword">null</span><span class="token punctuation">,</span> <span class="token keyword">null</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{</span>
    element<span class="token punctuation">.</span>_newWidget <span class="token operator">=</span> <span class="token keyword">this</span><span class="token punctuation">;</span>
    element<span class="token punctuation">.</span><span class="token function">markNeedsBuild</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
  <span class="token keyword">return</span> element<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x8BE5;&#x65B9;&#x6CD5;&#x8D1F;&#x8D23;&#x521B;&#x5EFA;&#x6839;element&#xFF0C;&#x5373;<code>RenderObjectToWidgetElement</code>&#xFF0C;&#x5E76;&#x4E14;&#x5C06;element&#x4E0E;widget &#x8FDB;&#x884C;&#x5173;&#x8054;&#xFF0C;&#x5373;&#x521B;&#x5EFA;&#x51FA; widget&#x6811;&#x5BF9;&#x5E94;&#x7684;element&#x6811;&#x3002;&#x5982;&#x679C;element &#x5DF2;&#x7ECF;&#x521B;&#x5EFA;&#x8FC7;&#x4E86;&#xFF0C;&#x5219;&#x5C06;&#x6839;element &#x4E2D;&#x5173;&#x8054;&#x7684;widget &#x8BBE;&#x4E3A;&#x65B0;&#x7684;&#xFF0C;&#x7531;&#x6B64;&#x53EF;&#x4EE5;&#x770B;&#x51FA;element &#x53EA;&#x4F1A;&#x521B;&#x5EFA;&#x4E00;&#x6B21;&#xFF0C;&#x540E;&#x9762;&#x4F1A;&#x8FDB;&#x884C;&#x590D;&#x7528;&#x3002;&#x90A3;&#x4E48;<code>BuildOwner</code>&#x662F;&#x4EC0;&#x4E48;&#x5462;&#xFF1F;&#x5176;&#x5B9E;&#x4ED6;&#x5C31;&#x662F;widget framework&#x7684;&#x7BA1;&#x7406;&#x7C7B;&#xFF0C;&#x5B83;&#x8DDF;&#x8E2A;&#x54EA;&#x4E9B;widget&#x9700;&#x8981;&#x91CD;&#x65B0;&#x6784;&#x5EFA;&#x3002;</p>
<h3 id="&#x6E32;&#x67D3;">&#x6E32;&#x67D3;</h3>
<p>&#x56DE;&#x5230;<code>runApp</code>&#x7684;&#x5B9E;&#x73B0;&#x4E2D;&#xFF0C;&#x5F53;&#x8C03;&#x7528;&#x5B8C;<code>attachRootWidget</code>&#x540E;&#xFF0C;&#x6700;&#x540E;&#x4E00;&#x884C;&#x4F1A;&#x8C03;&#x7528; <code>WidgetsFlutterBinding</code> &#x5B9E;&#x4F8B;&#x7684; <code>scheduleWarmUpFrame()</code> &#x65B9;&#x6CD5;&#xFF0C;&#x8BE5;&#x65B9;&#x6CD5;&#x7684;&#x5B9E;&#x73B0;&#x5728;<code>SchedulerBinding</code> &#x4E2D;&#xFF0C;&#x5B83;&#x88AB;&#x8C03;&#x7528;&#x540E;&#x4F1A;&#x7ACB;&#x5373;&#x8FDB;&#x884C;&#x4E00;&#x6B21;&#x7ED8;&#x5236;&#xFF08;&#x800C;&#x4E0D;&#x662F;&#x7B49;&#x5F85;&quot;vsync&quot; &#x4FE1;&#x53F7;&#xFF09;&#xFF0C;&#x5728;&#x6B64;&#x6B21;&#x7ED8;&#x5236;&#x7ED3;&#x675F;&#x524D;&#xFF0C;&#x8BE5;&#x65B9;&#x6CD5;&#x4F1A;&#x9501;&#x5B9A;&#x4E8B;&#x4EF6;&#x5206;&#x53D1;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x8BF4;&#x5728;&#x672C;&#x6B21;&#x7ED8;&#x5236;&#x7ED3;&#x675F;&#x5B8C;&#x6210;&#x4E4B;&#x524D;Flutter&#x5C06;&#x4E0D;&#x4F1A;&#x54CD;&#x5E94;&#x5404;&#x79CD;&#x4E8B;&#x4EF6;&#xFF0C;&#x8FD9;&#x53EF;&#x4EE5;&#x4FDD;&#x8BC1;&#x5728;&#x7ED8;&#x5236;&#x8FC7;&#x7A0B;&#x4E2D;&#x4E0D;&#x4F1A;&#x518D;&#x89E6;&#x53D1;&#x65B0;&#x7684;&#x91CD;&#x7ED8;&#x3002;&#x4E0B;&#x9762;&#x662F;<code>scheduleWarmUpFrame()</code> &#x65B9;&#x6CD5;&#x7684;&#x90E8;&#x5206;&#x5B9E;&#x73B0;(&#x7701;&#x7565;&#x4E86;&#x65E0;&#x5173;&#x4EE3;&#x7801;)&#xFF1A;</p>
<pre class="language-"><code class="lang-dart"><span class="token keyword">void</span> <span class="token function">scheduleWarmUpFrame</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
  Timer<span class="token punctuation">.</span><span class="token function">run</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token function">handleBeginFrame</span><span class="token punctuation">(</span><span class="token keyword">null</span><span class="token punctuation">)</span><span class="token punctuation">;</span> 
  <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  Timer<span class="token punctuation">.</span><span class="token function">run</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token function">handleDrawFrame</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>  
    <span class="token function">resetEpoch</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token comment">// &#x9501;&#x5B9A;&#x4E8B;&#x4EF6;</span>
  <span class="token function">lockEvents</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token keyword">async</span> <span class="token punctuation">{</span>
    <span class="token keyword">await</span> endOfFrame<span class="token punctuation">;</span>
    Timeline<span class="token punctuation">.</span><span class="token function">finishSync</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
 <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x53EF;&#x4EE5;&#x770B;&#x5230;&#x8BE5;&#x65B9;&#x6CD5;&#x4E2D;&#x4E3B;&#x8981;&#x8C03;&#x7528;&#x4E86;<code>handleBeginFrame()</code> &#x548C; <code>handleDrawFrame()</code> &#x4E24;&#x4E2A;&#x65B9;&#x6CD5;&#xFF0C;&#x5728;&#x770B;&#x8FD9;&#x4E24;&#x4E2A;&#x65B9;&#x6CD5;&#x4E4B;&#x524D;&#x6211;&#x4EEC;&#x9996;&#x5148;&#x4E86;&#x89E3;&#x4E00;&#x4E0B;Frame &#x548C; FrameCallback &#x7684;&#x6982;&#x5FF5;&#xFF1A;</p>
<ul>
<li><p>Frame: &#x4E00;&#x6B21;&#x7ED8;&#x5236;&#x8FC7;&#x7A0B;&#xFF0C;&#x6211;&#x4EEC;&#x79F0;&#x5176;&#x4E3A;&#x4E00;&#x5E27;&#x3002;Flutter engine&#x53D7;&#x663E;&#x793A;&#x5668;&#x5782;&#x76F4;&#x540C;&#x6B65;&#x4FE1;&#x53F7;&quot;VSync&quot;&#x7684;&#x9A71;&#x4F7F;&#x4E0D;&#x65AD;&#x7684;&#x89E6;&#x53D1;&#x7ED8;&#x5236;&#x3002;&#x6211;&#x4EEC;&#x4E4B;&#x524D;&#x8BF4;&#x7684;Flutter&#x53EF;&#x4EE5;&#x5B9E;&#x73B0;60fps&#xFF08;Frame Per-Second&#xFF09;&#xFF0C;&#x5C31;&#x662F;&#x6307;&#x4E00;&#x79D2;&#x949F;&#x53EF;&#x4EE5;&#x89E6;&#x53D1;60&#x6B21;&#x91CD;&#x7ED8;&#xFF0C;FPS&#x503C;&#x8D8A;&#x5927;&#xFF0C;&#x754C;&#x9762;&#x5C31;&#x8D8A;&#x6D41;&#x7545;&#x3002;</p>
</li>
<li><p>FrameCallback&#xFF1A;<code>SchedulerBinding</code> &#x7C7B;&#x4E2D;&#x6709;&#x4E09;&#x4E2A;FrameCallback&#x56DE;&#x8C03;&#x961F;&#x5217;&#xFF0C; &#x5728;&#x4E00;&#x6B21;&#x7ED8;&#x5236;&#x8FC7;&#x7A0B;&#x4E2D;&#xFF0C;&#x8FD9;&#x4E09;&#x4E2A;&#x56DE;&#x8C03;&#x961F;&#x5217;&#x4F1A;&#x653E;&#x5728;&#x4E0D;&#x540C;&#x65F6;&#x673A;&#x88AB;&#x6267;&#x884C;&#xFF1A;</p>
<ol>
<li><code>transientCallbacks</code>&#xFF1A;&#x7528;&#x4E8E;&#x5B58;&#x653E;&#x4E00;&#x4E9B;&#x4E34;&#x65F6;&#x56DE;&#x8C03;&#xFF0C;&#x4E00;&#x822C;&#x5B58;&#x653E;&#x52A8;&#x753B;&#x56DE;&#x8C03;&#x3002;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;<code>SchedulerBinding.instance.scheduleFrameCallback</code> &#x6DFB;&#x52A0;&#x56DE;&#x8C03;&#x3002;</li>
<li><code>persistentCallbacks</code>&#xFF1A;&#x7528;&#x4E8E;&#x5B58;&#x653E;&#x4E00;&#x4E9B;&#x6301;&#x4E45;&#x7684;&#x56DE;&#x8C03;&#xFF0C;&#x4E0D;&#x80FD;&#x5728;&#x6B64;&#x7C7B;&#x56DE;&#x8C03;&#x4E2D;&#x518D;&#x8BF7;&#x6C42;&#x65B0;&#x7684;&#x7ED8;&#x5236;&#x5E27;&#xFF0C;&#x6301;&#x4E45;&#x56DE;&#x8C03;&#x4E00;&#x7ECF;&#x6CE8;&#x518C;&#x5219;&#x4E0D;&#x80FD;&#x79FB;&#x9664;&#x3002;<code>SchedulerBinding.instance.addPersitentFrameCallback()</code>&#xFF0C;&#x8FD9;&#x4E2A;&#x56DE;&#x8C03;&#x4E2D;&#x5904;&#x7406;&#x4E86;&#x5E03;&#x5C40;&#x4E0E;&#x7ED8;&#x5236;&#x5DE5;&#x4F5C;&#x3002;</li>
<li><code>postFrameCallbacks</code>&#xFF1A;&#x5728;Frame&#x7ED3;&#x675F;&#x65F6;&#x53EA;&#x4F1A;&#x88AB;&#x8C03;&#x7528;&#x4E00;&#x6B21;&#xFF0C;&#x8C03;&#x7528;&#x540E;&#x4F1A;&#x88AB;&#x7CFB;&#x7EDF;&#x79FB;&#x9664;&#xFF0C;&#x53EF;&#x7531; <code>SchedulerBinding.instance.addPostFrameCallback()</code> &#x6CE8;&#x518C;&#xFF0C;&#x6CE8;&#x610F;&#xFF0C;&#x4E0D;&#x8981;&#x5728;&#x6B64;&#x7C7B;&#x56DE;&#x8C03;&#x4E2D;&#x518D;&#x89E6;&#x53D1;&#x65B0;&#x7684;Frame&#xFF0C;&#x8FD9;&#x53EF;&#x4EE5;&#x4F1A;&#x5BFC;&#x81F4;&#x5FAA;&#x73AF;&#x5237;&#x65B0;&#x3002;</li>
</ol>
</li>
</ul>
<p>&#x73B0;&#x5728;&#x8BF7;&#x8BFB;&#x8005;&#x81EA;&#x884C;&#x67E5;&#x770B;<code>handleBeginFrame()</code> &#x548C; <code>handleDrawFrame()</code> &#x4E24;&#x4E2A;&#x65B9;&#x6CD5;&#x7684;&#x6E90;&#x7801;&#xFF0C;&#x53EF;&#x4EE5;&#x53D1;&#x73B0;&#x524D;&#x8005;&#x4E3B;&#x8981;&#x662F;&#x6267;&#x884C;&#x4E86;<code>transientCallbacks</code>&#x961F;&#x5217;&#xFF0C;&#x800C;&#x540E;&#x8005;&#x6267;&#x884C;&#x4E86; <code>persistentCallbacks</code> &#x548C; <code>postFrameCallbacks</code> &#x961F;&#x5217;&#x3002;</p>
<h3 id="&#x7ED8;&#x5236;">&#x7ED8;&#x5236;</h3>
<p>&#x6E32;&#x67D3;&#x548C;&#x7ED8;&#x5236;&#x903B;&#x8F91;&#x5728;<code>RendererBinding</code>&#x4E2D;&#x5B9E;&#x73B0;&#xFF0C;&#x67E5;&#x770B;&#x5176;&#x6E90;&#x7801;&#xFF0C;&#x53D1;&#x73B0;&#x5728;&#x5176;<code>initInstances()</code>&#x65B9;&#x6CD5;&#x4E2D;&#x6709;&#x5982;&#x4E0B;&#x4EE3;&#x7801;&#xFF1A;</p>
<pre class="language-"><code class="lang-dart"><span class="token keyword">void</span> <span class="token function">initInstances</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span> <span class="token comment">//&#x7701;&#x7565;&#x65E0;&#x5173;&#x4EE3;&#x7801;</span>

  <span class="token comment">//&#x76D1;&#x542C;Window&#x5BF9;&#x8C61;&#x7684;&#x4E8B;&#x4EF6;  </span>
  ui<span class="token punctuation">.</span>window
    <span class="token punctuation">.</span><span class="token punctuation">.</span>onMetricsChanged <span class="token operator">=</span> handleMetricsChanged
    <span class="token punctuation">.</span><span class="token punctuation">.</span>onTextScaleFactorChanged <span class="token operator">=</span> handleTextScaleFactorChanged
    <span class="token punctuation">.</span><span class="token punctuation">.</span>onSemanticsEnabledChanged <span class="token operator">=</span> _handleSemanticsEnabledChanged
    <span class="token punctuation">.</span><span class="token punctuation">.</span>onSemanticsAction <span class="token operator">=</span> _handleSemanticsAction<span class="token punctuation">;</span>

  <span class="token comment">//&#x6DFB;&#x52A0;PersistentFrameCallback    </span>
  <span class="token function">addPersistentFrameCallback</span><span class="token punctuation">(</span>_handlePersistentFrameCallback<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x6211;&#x4EEC;&#x770B;&#x6700;&#x540E;&#x4E00;&#x884C;&#xFF0C;&#x901A;&#x8FC7;<code>addPersistentFrameCallback</code> &#x5411;<code>persistentCallbacks</code>&#x961F;&#x5217;&#x6DFB;&#x52A0;&#x4E86;&#x4E00;&#x4E2A;&#x56DE;&#x8C03; <code>_handlePersistentFrameCallback</code>:</p>
<pre class="language-"><code class="lang-dart"><span class="token keyword">void</span> <span class="token function">_handlePersistentFrameCallback</span><span class="token punctuation">(</span>Duration timeStamp<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token function">drawFrame</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x8BE5;&#x65B9;&#x6CD5;&#x76F4;&#x63A5;&#x8C03;&#x7528;&#x4E86;<code>RendererBinding</code>&#x7684;<code>drawFrame()</code>&#x65B9;&#x6CD5;&#xFF1A;</p>
<pre class="language-"><code class="lang-dart"><span class="token keyword">void</span> <span class="token function">drawFrame</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">assert</span><span class="token punctuation">(</span>renderView <span class="token operator">!=</span> <span class="token keyword">null</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  pipelineOwner<span class="token punctuation">.</span><span class="token function">flushLayout</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//&#x5E03;&#x5C40;</span>
  pipelineOwner<span class="token punctuation">.</span><span class="token function">flushCompositingBits</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//&#x91CD;&#x7ED8;&#x4E4B;&#x524D;&#x7684;&#x9884;&#x5904;&#x7406;&#x64CD;&#x4F5C;&#xFF0C;&#x68C0;&#x67E5;RenderObject&#x662F;&#x5426;&#x9700;&#x8981;&#x91CD;&#x7ED8;</span>
  pipelineOwner<span class="token punctuation">.</span><span class="token function">flushPaint</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// &#x91CD;&#x7ED8;</span>
  renderView<span class="token punctuation">.</span><span class="token function">compositeFrame</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// &#x5C06;&#x9700;&#x8981;&#x7ED8;&#x5236;&#x7684;&#x6BD4;&#x7279;&#x6570;&#x636E;&#x53D1;&#x7ED9;GPU</span>
  pipelineOwner<span class="token punctuation">.</span><span class="token function">flushSemantics</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// this also sends the semantics to the OS.</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x6211;&#x4EEC;&#x770B;&#x770B;&#x8FD9;&#x4E9B;&#x65B9;&#x6CD5;&#x5206;&#x522B;&#x505A;&#x4E86;&#x4EC0;&#x4E48;&#xFF1A;</p>
<h4 id="flushlayout">flushLayout()</h4>
<pre class="language-"><code class="lang-dart"><span class="token keyword">void</span> <span class="token function">flushLayout</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
   <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
    <span class="token keyword">while</span> <span class="token punctuation">(</span>_nodesNeedingLayout<span class="token punctuation">.</span>isNotEmpty<span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token keyword">final</span> List<span class="token operator">&lt;</span>RenderObject<span class="token operator">&gt;</span> dirtyNodes <span class="token operator">=</span> _nodesNeedingLayout<span class="token punctuation">;</span>
      _nodesNeedingLayout <span class="token operator">=</span> <span class="token operator">&lt;</span>RenderObject<span class="token operator">&gt;</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
      <span class="token keyword">for</span> <span class="token punctuation">(</span>RenderObject node <span class="token keyword">in</span> 
           dirtyNodes<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token function">sort</span><span class="token punctuation">(</span><span class="token punctuation">(</span>RenderObject a<span class="token punctuation">,</span> RenderObject b<span class="token punctuation">)</span> <span class="token operator">=</span><span class="token operator">&gt;</span> a<span class="token punctuation">.</span>depth <span class="token operator">-</span> b<span class="token punctuation">.</span>depth<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span>node<span class="token punctuation">.</span>_needsLayout <span class="token operator">&amp;&amp;</span> node<span class="token punctuation">.</span>owner <span class="token operator">==</span> <span class="token keyword">this</span><span class="token punctuation">)</span>
          node<span class="token punctuation">.</span><span class="token function">_layoutWithoutResize</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
      <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>
  <span class="token punctuation">}</span> 
<span class="token punctuation">}</span>
</code></pre>
<p>&#x6E90;&#x7801;&#x5F88;&#x7B80;&#x5355;&#xFF0C;&#x8BE5;&#x65B9;&#x6CD5;&#x4E3B;&#x8981;&#x4EFB;&#x52A1;&#x662F;&#x66F4;&#x65B0;&#x4E86;&#x6240;&#x6709;&#x88AB;&#x6807;&#x8BB0;&#x4E3A;&#x201C;dirty&#x201D;&#x7684;<code>RenderObject</code>&#x7684;&#x5E03;&#x5C40;&#x4FE1;&#x606F;&#x3002;&#x4E3B;&#x8981;&#x7684;&#x52A8;&#x4F5C;&#x53D1;&#x751F;&#x5728;<code>node._layoutWithoutResize()</code>&#x65B9;&#x6CD5;&#x4E2D;&#xFF0C;&#x8BE5;&#x65B9;&#x6CD5;&#x4E2D;&#x4F1A;&#x8C03;&#x7528;<code>performLayout()</code>&#x8FDB;&#x884C;&#x91CD;&#x65B0;&#x5E03;&#x5C40;&#x3002;</p>
<h4 id="flushcompositingbits">flushCompositingBits()</h4>
<pre class="language-"><code class="lang-dart"><span class="token keyword">void</span> <span class="token function">flushCompositingBits</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  _nodesNeedingCompositingBitsUpdate<span class="token punctuation">.</span><span class="token function">sort</span><span class="token punctuation">(</span>
      <span class="token punctuation">(</span>RenderObject a<span class="token punctuation">,</span> RenderObject b<span class="token punctuation">)</span> <span class="token operator">=</span><span class="token operator">&gt;</span> a<span class="token punctuation">.</span>depth <span class="token operator">-</span> b<span class="token punctuation">.</span>depth
  <span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token keyword">for</span> <span class="token punctuation">(</span>RenderObject node <span class="token keyword">in</span> _nodesNeedingCompositingBitsUpdate<span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span>node<span class="token punctuation">.</span>_needsCompositingBitsUpdate <span class="token operator">&amp;&amp;</span> node<span class="token punctuation">.</span>owner <span class="token operator">==</span> <span class="token keyword">this</span><span class="token punctuation">)</span>
      node<span class="token punctuation">.</span><span class="token function">_updateCompositingBits</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//&#x66F4;&#x65B0;RenderObject.needsCompositing&#x5C5E;&#x6027;&#x503C;</span>
  <span class="token punctuation">}</span>
  _nodesNeedingCompositingBitsUpdate<span class="token punctuation">.</span><span class="token function">clear</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x68C0;&#x67E5;<code>RenderObject</code>&#x662F;&#x5426;&#x9700;&#x8981;&#x91CD;&#x7ED8;&#xFF0C;&#x7136;&#x540E;&#x66F4;&#x65B0;<code>RenderObject.needsCompositing</code>&#x5C5E;&#x6027;&#xFF0C;&#x5982;&#x679C;&#x8BE5;&#x5C5E;&#x6027;&#x503C;&#x88AB;&#x6807;&#x8BB0;&#x4E3A;<code>true</code>&#x5219;&#x9700;&#x8981;&#x91CD;&#x7ED8;&#x3002;</p>
<h4 id="flushpaint">flushPaint()</h4>
<pre class="language-"><code class="lang-dart"><span class="token keyword">void</span> <span class="token function">flushPaint</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
 <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
  <span class="token keyword">try</span> <span class="token punctuation">{</span>
    <span class="token keyword">final</span> List<span class="token operator">&lt;</span>RenderObject<span class="token operator">&gt;</span> dirtyNodes <span class="token operator">=</span> _nodesNeedingPaint<span class="token punctuation">;</span> 
    _nodesNeedingPaint <span class="token operator">=</span> <span class="token operator">&lt;</span>RenderObject<span class="token operator">&gt;</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
    <span class="token comment">// &#x53CD;&#x5411;&#x904D;&#x5386;&#x9700;&#x8981;&#x91CD;&#x7ED8;&#x7684;RenderObject</span>
    <span class="token keyword">for</span> <span class="token punctuation">(</span>RenderObject node <span class="token keyword">in</span> 
         dirtyNodes<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token function">sort</span><span class="token punctuation">(</span><span class="token punctuation">(</span>RenderObject a<span class="token punctuation">,</span> RenderObject b<span class="token punctuation">)</span> <span class="token operator">=</span><span class="token operator">&gt;</span> b<span class="token punctuation">.</span>depth <span class="token operator">-</span> a<span class="token punctuation">.</span>depth<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token keyword">if</span> <span class="token punctuation">(</span>node<span class="token punctuation">.</span>_needsPaint <span class="token operator">&amp;&amp;</span> node<span class="token punctuation">.</span>owner <span class="token operator">==</span> <span class="token keyword">this</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span>node<span class="token punctuation">.</span>_layer<span class="token punctuation">.</span>attached<span class="token punctuation">)</span> <span class="token punctuation">{</span>
          <span class="token comment">// &#x771F;&#x6B63;&#x7684;&#x7ED8;&#x5236;&#x903B;&#x8F91;  </span>
          PaintingContext<span class="token punctuation">.</span><span class="token function">repaintCompositedChild</span><span class="token punctuation">(</span>node<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{</span>
          node<span class="token punctuation">.</span><span class="token function">_skippedPaintingOnLayer</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
      <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>
  <span class="token punctuation">}</span> 
<span class="token punctuation">}</span>
</code></pre>
<p>&#x8BE5;&#x65B9;&#x6CD5;&#x8FDB;&#x884C;&#x4E86;&#x6700;&#x7EC8;&#x7684;&#x7ED8;&#x5236;&#xFF0C;&#x53EF;&#x4EE5;&#x770B;&#x51FA;&#x5B83;&#x4E0D;&#x662F;&#x91CD;&#x7ED8;&#x4E86;&#x6240;&#x6709; <code>RenderObject</code>&#xFF0C;&#x800C;&#x662F;&#x53EA;&#x91CD;&#x7ED8;&#x4E86;&#x9700;&#x8981;&#x91CD;&#x7ED8;&#x7684; <code>RenderObject</code>&#x3002;&#x771F;&#x6B63;&#x7684;&#x7ED8;&#x5236;&#x662F;&#x901A;&#x8FC7;<code>PaintingContext.repaintCompositedChild()</code>&#x6765;&#x7ED8;&#x5236;&#x7684;&#xFF0C;&#x8BE5;&#x65B9;&#x6CD5;&#x6700;&#x7EC8;&#x4F1A;&#x8C03;&#x7528;Flutter engine&#x63D0;&#x4F9B;&#x7684;Canvas API&#x6765;&#x5B8C;&#x6210;&#x7ED8;&#x5236;&#x3002;</p>
<h4 id="compositeframe">compositeFrame()</h4>
<pre class="language-"><code class="lang-dart"><span class="token keyword">void</span> <span class="token function">compositeFrame</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
  <span class="token keyword">try</span> <span class="token punctuation">{</span>
    <span class="token keyword">final</span> ui<span class="token punctuation">.</span>SceneBuilder builder <span class="token operator">=</span> ui<span class="token punctuation">.</span><span class="token function">SceneBuilder</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">final</span> ui<span class="token punctuation">.</span>Scene scene <span class="token operator">=</span> layer<span class="token punctuation">.</span><span class="token function">buildScene</span><span class="token punctuation">(</span>builder<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span>automaticSystemUiAdjustment<span class="token punctuation">)</span>
      <span class="token function">_updateSystemChrome</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    ui<span class="token punctuation">.</span>window<span class="token punctuation">.</span><span class="token function">render</span><span class="token punctuation">(</span>scene<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//&#x8C03;&#x7528;Flutter engine&#x7684;&#x6E32;&#x67D3;API</span>
    scene<span class="token punctuation">.</span><span class="token function">dispose</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> 
  <span class="token punctuation">}</span> <span class="token keyword">finally</span> <span class="token punctuation">{</span>
    Timeline<span class="token punctuation">.</span><span class="token function">finishSync</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x8FD9;&#x4E2A;&#x65B9;&#x6CD5;&#x4E2D;&#x6709;&#x4E00;&#x4E2A;<code>Scene</code>&#x5BF9;&#x8C61;&#xFF0C;Scene&#x5BF9;&#x8C61;&#x662F;&#x4E00;&#x4E2A;&#x6570;&#x636E;&#x7ED3;&#x6784;&#xFF0C;&#x4FDD;&#x5B58;&#x6700;&#x7EC8;&#x6E32;&#x67D3;&#x540E;&#x7684;&#x50CF;&#x7D20;&#x4FE1;&#x606F;&#x3002;&#x8FD9;&#x4E2A;&#x65B9;&#x6CD5;&#x5C06;Canvas&#x753B;&#x597D;&#x7684;<code>Scene</code>&#x4F20;&#x7ED9;<code>window.render()</code>&#x65B9;&#x6CD5;&#xFF0C;&#x8BE5;&#x65B9;&#x6CD5;&#x4F1A;&#x76F4;&#x63A5;&#x5C06;scene&#x4FE1;&#x606F;&#x53D1;&#x9001;&#x7ED9;Flutter engine&#xFF0C;&#x6700;&#x7EC8;&#x7531;engine&#x5C06;&#x56FE;&#x50CF;&#x753B;&#x5728;&#x8BBE;&#x5907;&#x5C4F;&#x5E55;&#x4E0A;&#x3002;</p>
<h4 id="&#x6700;&#x540E;">&#x6700;&#x540E;</h4>
<p>&#x9700;&#x8981;&#x6CE8;&#x610F;&#x7684;&#x662F;&#xFF1A;&#x7531;&#x4E8E;<code>RendererBinding</code>&#x53EA;&#x662F;&#x4E00;&#x4E2A;mixin&#xFF0C;&#x800C;with&#x5B83;&#x7684;&#x662F;<code>WidgetsBinding</code>&#xFF0C;&#x6240;&#x4EE5;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x770B;&#x770B;<code>WidgetsBinding</code>&#x4E2D;&#x662F;&#x5426;&#x91CD;&#x5199;&#x8BE5;&#x65B9;&#x6CD5;&#xFF0C;&#x67E5;&#x770B;<code>WidgetsBinding</code>&#x7684;<code>drawFrame()</code>&#x65B9;&#x6CD5;&#x6E90;&#x7801;&#xFF1A;</p>
<pre class="language-"><code class="lang-dart"><span class="token metadata symbol">@override</span>
<span class="token keyword">void</span> <span class="token function">drawFrame</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
 <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token comment">//&#x7701;&#x7565;&#x65E0;&#x5173;&#x4EE3;&#x7801;</span>
  <span class="token keyword">try</span> <span class="token punctuation">{</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span>renderViewElement <span class="token operator">!=</span> <span class="token keyword">null</span><span class="token punctuation">)</span>
      buildOwner<span class="token punctuation">.</span><span class="token function">buildScope</span><span class="token punctuation">(</span>renderViewElement<span class="token punctuation">)</span><span class="token punctuation">;</span> 
    <span class="token keyword">super</span><span class="token punctuation">.</span><span class="token function">drawFrame</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//&#x8C03;&#x7528;RendererBinding&#x7684;drawFrame()&#x65B9;&#x6CD5;</span>
    buildOwner<span class="token punctuation">.</span><span class="token function">finalizeTree</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span> 
<span class="token punctuation">}</span>
</code></pre>
<p>&#x6211;&#x4EEC;&#x53D1;&#x73B0;&#x5728;&#x8C03;&#x7528;<code>RendererBinding.drawFrame()</code>&#x65B9;&#x6CD5;&#x524D;&#x4F1A;&#x8C03;&#x7528; <code>buildOwner.buildScope()</code> &#xFF08;&#x975E;&#x9996;&#x6B21;&#x7ED8;&#x5236;&#xFF09;&#xFF0C;&#x8BE5;&#x65B9;&#x6CD5;&#x4F1A;&#x5C06;&#x88AB;&#x6807;&#x8BB0;&#x4E3A;&#x201C;dirty&#x201D; &#x7684; element &#x8FDB;&#x884C; <code>rebuild()</code> &#x3002;</p>
<h3 id="&#x603B;&#x7ED3;">&#x603B;&#x7ED3;</h3>
<p>&#x672C;&#x8282;&#x4ECB;&#x7ECD;&#x4E86;Flutter APP&#x4ECE;&#x542F;&#x52A8;&#x5230;&#x663E;&#x793A;&#x5230;&#x5C4F;&#x5E55;&#x4E0A;&#x7684;&#x4E3B;&#x6D41;&#x7A0B;&#xFF0C;&#x8BFB;&#x8005;&#x53EF;&#x4EE5;&#x7ED3;&#x5408;&#x524D;&#x9762;&#x7AE0;&#x8282;&#x5BF9;Widget&#x3001;Element&#x4EE5;&#x53CA;RenderObject&#x7684;&#x4ECB;&#x7ECD;&#x6765;&#x52A0;&#x5F3A;&#x7EC6;&#x8282;&#x7406;&#x89E3;&#x3002;</p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="render_object.html" class="navigation navigation-prev " aria-label="Previous page: 14.3：RenderObject与RenderBox">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="image_and_cache.html" class="navigation navigation-next " aria-label="Next page: 14.5：Flutter图片加载与缓存">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"14.4：Flutter从启动到显示","level":"3.7.4","depth":2,"next":{"title":"14.5：Flutter图片加载与缓存","level":"3.7.5","depth":2,"path":"chapter14/image_and_cache.md","ref":"chapter14/image_and_cache.md","articles":[]},"previous":{"title":"14.3：RenderObject与RenderBox","level":"3.7.3","depth":2,"path":"chapter14/render_object.md","ref":"chapter14/render_object.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-search","search-pro","ace","splitter","prism","donate","-highlight"],"root":"docs","styles":{"website":"styles/website.css","ebook":"styles/ebook.css","pdf":"styles/pdf.css","mobi":"styles/mobi.css","epub":"styles/epub.css"},"pluginsConfig":{"prism":{"lang":{"shell":"bash"}},"ace":{},"splitter":{},"search-pro":{"cutWordLib":"nodejieba","defineWord":["Gitbook Use"]},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"donate":{"alipay":"","alipayText":"支付宝打赏","button":"赏","title":"","wechat":"https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action@1.0.3/docs/imgs/pay.jpeg","wechatText":"微信打赏"},"fontsettings":{"theme":"white","family":"sans","size":2},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"wendux 824783146@qq.com","bookRoot":"https://book.flutterchina.club/","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"《Flutter实战》","language":"zh-hans","links":{"sharing":{"all":null,"facebook":null,"google":null,"twitter":null,"weibo":null},"sidebar":{"<div><img height=20 style='position:relative; top:5px; padding-right:5px ' src='https://cdn.jsdelivr.net/gh/flutterchina/website@1.0/images/favicon.png'/> Flutter中文网</div>":"https://flutterchina.club"}},"gitbook":"*","description":"记录Gitbook的配置和一些插件的使用"},"file":{"path":"chapter14/flutter_app_startup.md","mtime":"2019-08-22T07:10:57.362Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-03-15T14:52:22.710Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>



    <script src="https://pcdn.flutterchina.club/gitbook/gitbook.js"></script>
    <script src="https://pcdn.flutterchina.club/gitbook/theme.js"></script>
    
        
        <script src="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
        
    
        
        <script src="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-search-pro/search.js"></script>
        
    
        
        <script src="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-ace/ace/ace.js"></script>
        
    
        
        <script src="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-ace/ace.js"></script>
        
    
        
        <script src="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-donate/plugin.js"></script>
        
    
        
        <script src="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    


<script src="https://pcdn.flutterchina.club/gitbook/pub.js"></script>
<script>
    hookAjax({
        open: function (arg, xhr) {
            if (location.hostname !== 'localhost') {
                if (arg[1][0] === '.') arg[1] = arg[1].slice(1);
                arg[1] = "https://pcdn.flutterchina.club" + arg[1].replace(".html", ".1")
            }
        },
        setRequestHeader: function (arg, xhr) {
            console.log(arg[0], arg[1]);
            if (arg[0] !== 'Accept') return true;
        },
        onload:function(){
            setTimeout(addAD);
        }
    })
</script>
</body>

</html>

